<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateActivitySeedingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //活动直播表
        //     没有为该表创建直播发文的时间字段，直接利用laravel的timestamps方式增加了一个created_at字段
        Schema::create('activity_seedings', function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();

            $table->integer('activity_id')->unsigned()->comment('活动id');
            $table->foreign('activity_id')->references('id')->on('activities');

            //必须填，如果活动只有一个城市，则默认
            $table->integer('city_id')->unsigned()->comment('当前图文对应的现场城市id');
            $table->foreign('city_id')->references('id')->on('cities');

            //活动运营人员在后台发布直播图文，类似微信公众号，可以发一个简单描述，以及最多九张图片
            //其他人可以点赞，后接评论(这是下一阶段要做的，第一阶段不考虑)
            $table->string('situation', 1000)->nullable()->comment('现场情况');

            $table->string('picture1', 200)->nullable()->comment('直播活动图片1');
            $table->string('picture2', 200)->nullable()->comment('直播活动图片2');
            $table->string('picture3', 200)->nullable()->comment('直播活动图片3');
            $table->string('picture4', 200)->nullable()->comment('直播活动图片4');
            $table->string('picture5', 200)->nullable()->comment('直播活动图片5');
            $table->string('picture6', 200)->nullable()->comment('直播活动图片6');
            $table->string('picture7', 200)->nullable()->comment('直播活动图片7');
            $table->string('picture8', 200)->nullable()->comment('直播活动图片8');
            $table->string('picture9', 200)->nullable()->comment('直播活动图片9');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('activity_seedings', function ($table) {
            $table->dropForeign(['activity_id']);
            $table->dropForeign(['city_id']);
        });
        Schema::dropIfExists('activity_seedings');
    }
}
